<?php

namespace Database\Seeders;

use App\Models\Category;
use Illuminate\Database\Seeder;
use App\Models\Archive;
use App\Models\User;
class ArchiveSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user_ids = User::pluck('id');
        $category_ids = Category::pluck('id');
        $faker = app(\Faker\Generator::class);
        $archives = Archive::factory()->times(100)->make()->each(function ($archive) use ($user_ids, $faker, $category_ids) {
            $archive->user_id = $faker->randomElement($user_ids);
            $archive->category_id = $faker->randomElement($category_ids);
            $archive->save();
        });
    }
}
